package com.xiaoma.h5testdemo.business.main.vm

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.xiaoma.common.extend.toLiveData
import com.xiaoma.common.utils.VmEvent
import com.xiaoma.h5testdemo.business.main.utils.XmFragmentStackManager
import com.xiaoma.h5testdemo.collect.CollectMgr
import com.xiaoma.h5testdemo.common.models.CollectEntity
import kotlinx.coroutines.launch

/**
 * author: liangjingbo
 * date: 2024/4/18
 * describe:
 */
class MainFrgVm : ViewModel() {


    private val _collectListLiveData = MutableLiveData<VmEvent<List<CollectEntity>>>()
    val collectListLiveData = _collectListLiveData.toLiveData()



    fun updateCollectList(){
        viewModelScope.launch {
            val collectList = CollectMgr.getCollectList()
            _collectListLiveData.postValue(VmEvent.data(collectList))
        }
    }

}